import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '检查名称',
    align:"center",
    dataIndex: 'name'
  },
  {
    title: '检查类型',
    align:"center",
    dataIndex: 'inspectType_dictText'
  },
  {
    title: '涉及危险源',
    align:"center",
    dataIndex: 'hazardName'
  },
  {
    title: '被检查单位',
    align:"center",
    dataIndex: 'jnitUnderInspection'
  },
  {
    title: '任务开始日期',
    align:"center",
    dataIndex: 'taskStartTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '任务结束日期',
    align:"center",
    dataIndex: 'taskEndTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '检查人',
    align:"center",
    dataIndex: 'examiner_dictText'
  },
  {
    title: '登记时间',
    align:"center",
    dataIndex: 'registrationTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '审批状态',
    align:"center",
    dataIndex: 'bpmStatus_dictText'
  },
  {
    title: '审批人',
    align:"center",
    dataIndex: 'approver_dictText'
  },
  {
    title: '附件',
    align:"center",
    dataIndex: 'attachments',
  },
  {
    title: '说明',
    align:"center",
    dataIndex: 'remark'
  },
  {
    title: '检查来源',
    align:"center",
    dataIndex: 'source'
  },
  {
    title: '是否使用检查表',
    align:"center",
    dataIndex: 'isNot_dictText'
  },
  {
    title: '组织检查单位',
    align:"center",
    dataIndex: 'inspectionUnit'
  },
  {
    title: '检查级别',
    align:"center",
    dataIndex: 'inspectionLevel_dictText'
  },
  {
    title: '检查种类',
    align:"center",
    dataIndex: 'inspectionType_dictText'
  },
  // {
  //   title: '删除标识',
  //   align:"center",
  //   dataIndex: 'deleted_dictText'
  // },
  {
    title: '任务状态',
    align:"center",
    dataIndex: 'status_dictText'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "检查名称",
    field: "name",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "检查类型",
    field: "inspectType",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"baseCheckType"
    },
    //colProps: {span: 6},
  },
  {
    label: "任务开始日期",
    field: "taskStartTime",
    component: 'RangePicker',
    componentProps: {
      valueType: 'Date',
    },
    //colProps: {span: 6},
  },
  {
    label: "检查人",
    field: "examiner",
    component: 'JSelectUserByDept',
    //colProps: {span: 6},
  },
  {
    label: "审批状态",
    field: "bpmStatus",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"baseCheckBpmType"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '检查名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '检查类型',
    field: 'inspectType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"baseCheckType"
    },
  },
  {
    label: '涉及危险源',
    field: 'hazardName',
    component: 'Input',
  },
  {
    label: '被检查单位',
    field: 'jnitUnderInspection',
    component: 'Input',
  },
  {
    label: '任务开始日期',
    field: 'taskStartTime',
    component: 'DatePicker',
  },
  {
    label: '任务结束日期',
    field: 'taskEndTime',
    component: 'DatePicker',
  },
  {
    label: '检查人',
    field: 'examiner',
    component: 'JSelectUserByDept',
    componentProps:{
      labelKey:'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入检查人!'},
      ];
     },
  },
  {
    label: '登记时间',
    field: 'registrationTime',
    component: 'DatePicker',
  },
  {
    label: '审批状态',
    field: 'bpmStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"baseCheckBpmType"
    },
  },
  {
    label: '审批人',
    field: 'approver',
    component: 'JSelectUserByDept',
    componentProps:{
      labelKey:'realname',
    },
  },
  {
    label: '附件',
    field: 'attachments',
    component: 'JUpload',
    componentProps:{
    },
  },
  {
    label: '说明',
    field: 'remark',
    component: 'InputTextArea',//TODO 注意string转换问题
  },
  {
    label: '检查来源',
    field: 'source',
    component: 'Input',
  },
  {
    label: '是否使用检查表',
    field: 'isNot',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"yn"
    },
  },
  {
    label: '组织检查单位',
    field: 'inspectionUnit',
    component: 'Input',
  },
  {
    label: '检查级别',
    field: 'inspectionLevel',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"inspectionLevel"
    },
  },
  {
    label: '检查种类',
    field: 'inspectionType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"inspectionType"
    },
  },
  {
    label: '删除标识',
    field: 'deleted',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"yn"
    },
  },
  {
    label: '任务状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"task_status"
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
	field: 'id',
	component: 'Input',
	show: false
  },
];

//子表列表数据
export const tbBaseCheckRecordColumns: BasicColumn[] = [
  {
    title: '所属任务',
    align:"center",
    dataIndex: 'taskId_dictText'
  },
  {
    title: '检查类型',
    align:"center",
    dataIndex: 'checkType_dictText'
  },
  // {
  //   title: '检查日期',
  //   align:"center",
  //   dataIndex: 'checkDate',
  //   customRender:({text}) =>{
  //     return !text?"":(text.length>10?text.substr(0,10):text)
  //   },
  // },
  // {
  //   title: '是否停产整顿',
  //   align:"center",
  //   dataIndex: 'resultStatus_dictText'
  // },
  {
    title: '检查序号',
    align:"center",
    dataIndex: 'checkName'
  },
  {
    title: '检查内容',
    align:"center",
    dataIndex: 'checkContent'
  },
  {
    title: '检查方式',
    align:"center",
    dataIndex: 'checkWay'
  },
  {
    title: '检查依据',
    align:"center",
    dataIndex: 'checkBasis'
  },
  {
    title: '适用场合',
    align:"center",
    dataIndex: 'applicablePlace'
  },
  {
    title: '检查人',
    align:"center",
    dataIndex: 'examiner_dictText'
  },
  // {
  //   title: '是否符合',
  //   align:"center",
  //   dataIndex: 'isConforms_dictText'
  // },
  // {
  //   title: '删除标记',
  //   align:"center",
  //   dataIndex: 'deleted_dictText'
  // },
];
//子表表单数据
export const tbBaseCheckRecordFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '所属任务',
    field: 'taskId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"tb_base_check_task,task_name,id"
    },
  },
  {
    label: '检查类型',
    field: 'checkType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"baseCheckType"
    },
  },
  {
    label: '检查日期',
    field: 'checkDate',
    component: 'DatePicker',
  },
  {
    label: '是否停产整顿',
    field: 'resultStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"yn"
    },
  },
  {
    label: '检查序号',
    field: 'checkName',
    component: 'Input',
    dynamicDisabled:true,
  },
  {
    label: '检查内容',
    field: 'checkContent',
    component: 'InputTextArea',
  },
  {
    label: '检查方式',
    field: 'checkWay',
    component: 'Input',
  },
  {
    label: '检查依据',
    field: 'checkBasis',
    component: 'Input',
  },
  {
    label: '适用场合',
    field: 'applicablePlace',
    component: 'Input',
  },
  {
    label: '检查人',
    field: 'examiner',
    component: 'JSelectUserByDept',
    componentProps:{
      labelKey:'realname',
    },
  },
  {
    label: '是否符合',
    field: 'isConforms',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"isConforms"
    },
  },
  {
    label: '删除标记',
    field: 'deleted',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"yn"
    },
  },
];
//子表列表数据
export const tbBaseCheckPlanApprovalRecordColumns: BasicColumn[] = [
  {
    title: '处理人',
    align:"center",
    dataIndex: 'processor_dictText'
  },
  {
    title: '操作',
    align:"center",
    dataIndex: 'controls'
  },
  {
    title: '处理结果',
    align:"center",
    dataIndex: 'processingResult'
  },
  {
    title: '处理意见',
    align:"center",
    dataIndex: 'handlingSuggestion'
  },
  {
    title: '操作时间',
    align:"center",
    dataIndex: 'operatingTime'
  },
];
//子表表单数据
export const tbBaseCheckPlanApprovalRecordFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '处理人',
    field: 'processor',
    component: 'JSelectUserByDept',
    componentProps:{
      labelKey:'realname',
    },
  },
  {
    label: '操作',
    field: 'controls',
    component: 'Input',
  },
  {
    label: '处理结果',
    field: 'processingResult',
    component: 'Input',
  },
  {
    label: '处理意见',
    field: 'handlingSuggestion',
    component: 'Input',
  },
  {
    label: '操作时间',
    field: 'operatingTime',
    component: 'DatePicker',
    componentProps: {
      showTime:true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '检查名称',order: 0,view: 'text', type: 'string',},
  inspectType: {title: '检查类型',order: 1,view: 'list', type: 'string',dictCode: 'baseCheckType',},
  hazardName: {title: '涉及危险源',order: 2,view: 'text', type: 'string',},
  jnitUnderInspection: {title: '被检查单位',order: 3,view: 'text', type: 'string',},
  taskStartTime: {title: '任务开始日期',order: 4,view: 'date', type: 'string',},
  taskEndTime: {title: '任务结束日期',order: 5,view: 'date', type: 'string',},
  examiner: {title: '检查人',order: 6,view: 'sel_user', type: 'string',},
  registrationTime: {title: '登记时间',order: 7,view: 'date', type: 'string',},
  bpmStatus: {title: '审批状态',order: 8,view: 'list', type: 'string',dictCode: 'baseCheckBpmType',},
  approver: {title: '审批人',order: 9,view: 'sel_user', type: 'string',},
  attachments: {title: '附件',order: 10,view: 'file', type: 'string',},
  remark: {title: '说明',order: 11,view: 'textarea', type: 'string',},
  source: {title: '检查来源',order: 12,view: 'text', type: 'string',},
  isNot: {title: '是否使用检查表',order: 13,view: 'radio', type: 'string',},
  inspectionUnit: {title: '组织检查单位',order: 14,view: 'text', type: 'string',},
  inspectionLevel: {title: '检查级别',order: 15,view: 'list', type: 'string',dictCode: 'inspectionLevel',},
  inspectionType: {title: '检查种类',order: 16,view: 'list', type: 'string',dictCode: 'inspectionType',},
  deleted: {title: '删除标识',order: 17,view: 'radio', type: 'string',},
  status: {title: '任务状态',order: 18,view: 'list', type: 'string',dictCode: 'task_status',},
};
